﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using Serialization;
using IDb;

namespace OMSWeb.service
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class DataHandler : IHttpHandler
    {
        HttpContext Context;
        string json = "";
        ISerializer jsonconvert = SerializerFactory.GetSerializer(SerializerStyle.Json);
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            Context = context;
            context.Response.ContentType = "text/plain";
            try
            {
                if (context.Request.Params["Action"] == "get")
                {
                    LoadDataToJSON();
                    context.Response.Write(json);

                }
            }
            catch (Exception err)
            {
            }
            context.Response.End();
        }


        void LoadDataToJSON()
        {
            switch (View)
            {
                case "Employee":
                    GetEmployee();
                    break;
                case "Home":
                    GetHome();
                    break;
            }
        }
        private void GetEmployee()
        {
           // List<employeeinfo> list = m_bll.GetModelList("");
            //string result = json_bll.Serialize<List<employeeinfo>>(list);
            //json = "{Rows:" + result + ",Total:" + list.Count + "}";
            
        }
        private void GetHome()
        {
            //List<homechargeinfo> list = home_bll.GetModelList("");
            //string result = json_bll.Serialize<List<homechargeinfo>>(list);
            //json = "{Rows:" + result + ",Total:" + list.Count + "}";

        }

        string View
        {
            get { return Context.Request.QueryString["View"]; }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
